Yet more Rubocopping

This commit is contained in:
Maruno17
2021-12-23 00:27:17 +00:00
parent 514fe13ca2
commit 132a16950d
171 changed files with 1455 additions and 1647 deletions

View File

@@ -361,13 +361,11 @@ def pbTrainerTypeEditor
if tr_type
case button
when Input::ACTION
if tr_type.is_a?(Symbol)
if pbConfirmMessageSerious("Delete this trainer type?")
GameData::TrainerType::DATA.delete(tr_type)
GameData::TrainerType.save
pbConvertTrainerData
pbMessage(_INTL("The Trainer type was deleted."))
end
if tr_type.is_a?(Symbol) && pbConfirmMessageSerious("Delete this trainer type?")
GameData::TrainerType::DATA.delete(tr_type)
GameData::TrainerType.save
pbConvertTrainerData
pbMessage(_INTL("The Trainer type was deleted."))
end
when Input::USE
if tr_type.is_a?(Symbol)
@@ -502,13 +500,11 @@ def pbTrainerBattleEditor
if trainer_id
case button
when Input::ACTION
if trainer_id.is_a?(Array)
if pbConfirmMessageSerious("Delete this trainer battle?")
tr_data = GameData::Trainer::DATA[trainer_id]
GameData::Trainer::DATA.delete(trainer_id)
modified = true
pbMessage(_INTL("The Trainer battle was deleted."))
end
if trainer_id.is_a?(Array) && pbConfirmMessageSerious("Delete this trainer battle?")
tr_data = GameData::Trainer::DATA[trainer_id]
GameData::Trainer::DATA.delete(trainer_id)
modified = true
pbMessage(_INTL("The Trainer battle was deleted."))
end
when Input::USE
if trainer_id.is_a?(Array) # Edit existing trainer
@@ -874,8 +870,8 @@ def pbItemEditor
[_INTL("Name"), ItemNameProperty, _INTL("Name of this item as displayed by the game.")],
[_INTL("NamePlural"), ItemNameProperty, _INTL("Plural name of this item as displayed by the game.")],
[_INTL("Pocket"), PocketProperty, _INTL("Pocket in the Bag where this item is stored.")],
[_INTL("Price"), LimitProperty.new(999999), _INTL("Purchase price of this item.")],
[_INTL("SellPrice"), LimitProperty.new(999999), _INTL("Sell price of this item. If blank, is half the purchase price.")],
[_INTL("Price"), LimitProperty.new(999_999), _INTL("Purchase price of this item.")],
[_INTL("SellPrice"), LimitProperty.new(999_999), _INTL("Sell price of this item. If blank, is half the purchase price.")],
[_INTL("Description"), StringProperty, _INTL("Description of this item")],
[_INTL("FieldUse"), EnumProperty.new(field_use_array), _INTL("How this item can be used outside of battle.")],
[_INTL("BattleUse"), EnumProperty.new(battle_use_array), _INTL("How this item can be used within a battle.")],
@@ -887,13 +883,11 @@ def pbItemEditor
if item
case button
when Input::ACTION
if item.is_a?(Symbol)
if pbConfirmMessageSerious("Delete this item?")
GameData::Item::DATA.delete(item)
GameData::Item.save
Compiler.write_items
pbMessage(_INTL("The item was deleted."))
end
if item.is_a?(Symbol) && pbConfirmMessageSerious("Delete this item?")
GameData::Item::DATA.delete(item)
GameData::Item.save
Compiler.write_items
pbMessage(_INTL("The item was deleted."))
end
when Input::USE
if item.is_a?(Symbol)
@@ -974,7 +968,7 @@ def pbItemEditorNew(default_name)
pocket = PocketProperty.set("", 0)
return if pocket == 0
# Choose a price
price = LimitProperty.new(999999).set(_INTL("Purchase price"), -1)
price = LimitProperty.new(999_999).set(_INTL("Purchase price"), -1)
return if price == -1
# Choose a description
description = StringProperty.set(_INTL("Description"), "")
@@ -1030,7 +1024,7 @@ def pbPokemonEditor
[_INTL("WildItemRare"), GameDataPoolProperty.new(:Item), _INTL("Item(s) rarely held by wild Pokémon of this species.")],
[_INTL("EggGroup 1"), GameDataProperty.new(:EggGroup), _INTL("Compatibility group (egg group) for breeding purposes.")],
[_INTL("EggGroup 2"), GameDataProperty.new(:EggGroup), _INTL("Compatibility group (egg group) for breeding purposes.")],
[_INTL("HatchSteps"), LimitProperty.new(99999), _INTL("Number of steps until an egg of this species hatches.")],
[_INTL("HatchSteps"), LimitProperty.new(99_999), _INTL("Number of steps until an egg of this species hatches.")],
[_INTL("Incense"), ItemProperty, _INTL("Item needed to be held by a parent to produce an egg of this species.")],
[_INTL("Offspring"), GameDataPoolProperty.new(:Species), _INTL("All possible species that an egg can be when breeding for an egg of this species (if blank, the egg can only be this species).")],
[_INTL("Evolutions"), EvolutionsProperty.new, _INTL("Evolution paths of this species.")],
@@ -1039,20 +1033,18 @@ def pbPokemonEditor
[_INTL("Color"), GameDataProperty.new(:BodyColor), _INTL("Pokémon's body color.")],
[_INTL("Shape"), GameDataProperty.new(:BodyShape), _INTL("Body shape of this species.")],
[_INTL("Habitat"), GameDataProperty.new(:Habitat), _INTL("The habitat of this species.")],
[_INTL("Generation"), LimitProperty.new(99999), _INTL("The number of the generation the Pokémon debuted in.")],
[_INTL("Generation"), LimitProperty.new(99_999), _INTL("The number of the generation the Pokémon debuted in.")],
[_INTL("Flags"), StringListProperty, _INTL("Words/phrases that distinguish this species from others.")]
]
pbListScreenBlock(_INTL("Pokémon species"), SpeciesLister.new(0, false)) { |button, species|
if species
case button
when Input::ACTION
if species.is_a?(Symbol)
if pbConfirmMessageSerious("Delete this species?")
GameData::Species::DATA.delete(species)
GameData::Species.save
Compiler.write_pokemon
pbMessage(_INTL("The species was deleted."))
end
if species.is_a?(Symbol) && pbConfirmMessageSerious("Delete this species?")
GameData::Species::DATA.delete(species)
GameData::Species.save
Compiler.write_pokemon
pbMessage(_INTL("The species was deleted."))
end
when Input::USE
if species.is_a?(Symbol)
@@ -1259,7 +1251,7 @@ def pbRegionalDexEditor(dex)
case pbMessage(_INTL("Save changes?"),
[_INTL("Yes"), _INTL("No"), _INTL("Cancel")], 3)
when 0 # Save all changes to Dex
dex.slice!(-1) while !dex[-1]
dex.slice!(-1) until dex[-1]
ret = dex
break
when 1 # Just quit

View File

@@ -48,7 +48,7 @@ class PokemonTilesetScene
def load_tileset(id)
@tileset = @tilesets_data[id]
@tilehelper.dispose if @tilehelper
@tilehelper&.dispose
@tilehelper = TileDrawingHelper.fromTileset(@tileset)
@x = 0
@y = 0
@@ -88,7 +88,7 @@ class PokemonTilesetScene
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])
textpos.push([terr.to_s, (xx * TILE_SIZE) + (TILE_SIZE / 2), (yy * TILE_SIZE) - 6, 2, TEXT_COLOR, TEXT_SHADOW_COLOR])
end
end
pbDrawTextPositions(@sprites["overlay"].bitmap, textpos)
@@ -188,9 +188,9 @@ class PokemonTilesetScene
]
case pbShowCommands(nil, commands, -1)
when 0
update_cursor_position(0, 99999)
update_cursor_position(0, 99_999)
when 1
update_cursor_position(0, -99999)
update_cursor_position(0, -99_999)
when 2
choose_tileset
end

View File

@@ -50,7 +50,7 @@ class SelectionSprite < Sprite
end
def dispose
@sprite.bitmap.dispose if @sprite.bitmap
@sprite.bitmap&.dispose
@othersprite = nil
@sprite.dispose
end
@@ -234,8 +234,8 @@ class MapScreenScene
otherdims = MapFactoryHelper.getMapDims(i)
x1 = (thissprite.x - othersprite.x) / 4
y1 = (thissprite.y - othersprite.y) / 4
if (x1 == otherdims[0] || x1 == -thisdims[0] ||
y1 == otherdims[1] || y1 == -thisdims[1])
if x1 == otherdims[0] || x1 == -thisdims[0] ||
y1 == otherdims[1] || y1 == -thisdims[1]
ret.push(i)
end
end

View File

@@ -21,11 +21,11 @@ def pbAutoPositionAll
metrics = GameData::SpeciesMetrics.get_species_form(sp.species, sp.form)
bitmap1 = GameData::Species.sprite_bitmap(sp.species, sp.form, nil, nil, nil, true)
bitmap2 = GameData::Species.sprite_bitmap(sp.species, sp.form)
if bitmap1 && bitmap1.bitmap # Player's y
if bitmap1&.bitmap # Player's y
metrics.back_sprite[0] = 0
metrics.back_sprite[1] = (bitmap1.height - (findBottom(bitmap1.bitmap) + 1)) / 2
end
if bitmap2 && bitmap2.bitmap # Foe's y
if bitmap2&.bitmap # Foe's y
metrics.front_sprite[0] = 0
metrics.front_sprite[1] = (bitmap2.height - (findBottom(bitmap2.bitmap) + 1)) / 2
metrics.front_sprite[1] += 4 # Just because
@@ -33,8 +33,8 @@ def pbAutoPositionAll
metrics.front_sprite_altitude = 0 # Shouldn't be used
metrics.shadow_x = 0
metrics.shadow_size = 2
bitmap1.dispose if bitmap1
bitmap2.dispose if bitmap2
bitmap1&.dispose
bitmap2&.dispose
end
GameData::SpeciesMetrics.save
Compiler.write_pokemon_metrics

View File

@@ -16,13 +16,13 @@ def pbSafeCopyFile(x, y, z = nil)
filedata = nil
if safeExists?(y)
different = false
if FileTest.size(x) != FileTest.size(y)
different = true
else
if FileTest.size(x) == FileTest.size(y)
filedata2 = ""
File.open(x, "rb") { |f| filedata = f.read }
File.open(y, "rb") { |f| filedata2 = f.read }
different = true if filedata != filedata2
else
different = true
end
if different
safetocopy = pbConfirmMessage(_INTL("A different file named '{1}' already exists. Overwrite it?", y))

View File

@@ -85,14 +85,14 @@ def pbSpriteHitTest(sprite, x, y, usealpha = true, wholecanvas = false)
return false if sprite.bitmap.disposed?
width = sprite.src_rect.width
height = sprite.src_rect.height
if !wholecanvas
if wholecanvas
xwidth = 0
xheight = 0
else
xwidth = width - 64
xheight = height - 64
width = 64 if width > 64 && !usealpha
height = 64 if height > 64 && !usealpha
else
xwidth = 0
xheight = 0
end
width = sprite.bitmap.width if width > sprite.bitmap.width
height = sprite.bitmap.height if height > sprite.bitmap.height
@@ -125,7 +125,7 @@ def pbSpriteHitTest(sprite, x, y, usealpha = true, wholecanvas = false)
bitmapX = sprite.src_rect.x + 192 - xmirror
end
color = sprite.bitmap.get_pixel(bitmapX, bitmapY)
return false if (color.alpha == 0)
return false if color.alpha == 0
end
return true
end
@@ -478,7 +478,7 @@ class AnimationCanvas < Sprite
def loadAnimation(anim)
@animation = anim
@animbitmap.dispose if @animbitmap
@animbitmap&.dispose
if @animation.graphic == ""
@animbitmap = nil
else
@@ -497,7 +497,7 @@ class AnimationCanvas < Sprite
end
def animbitmap=(value)
@animbitmap.dispose if @animbitmap
@animbitmap&.dispose
@animbitmap = value
(2...PBAnimation::MAX_SPRITES).each do |i|
@celsprites[i].bitmap = @animbitmap if @celsprites[i]
@@ -508,12 +508,12 @@ class AnimationCanvas < Sprite
def dispose
@user.dispose
@target.dispose
@animbitmap.dispose if @animbitmap
@selectedbitmap.dispose if @selectedbitmap
@celbitmap.dispose if @celbitmap
self.bitmap.dispose if self.bitmap
@animbitmap&.dispose
@selectedbitmap&.dispose
@celbitmap&.dispose
self.bitmap&.dispose
PBAnimation::MAX_SPRITES.times do |i|
@celsprites[i].dispose if @celsprites[i]
@celsprites[i]&.dispose
end
super
end
@@ -616,7 +616,9 @@ class AnimationCanvas < Sprite
def setPreviousFrame(i)
if @currentframe > 0
cel = @animation[@currentframe - 1][i]
if cel != nil
if cel.nil?
@lastframesprites[i].visible = false
else
@lastframesprites[i].ox = 32
@lastframesprites[i].oy = 32
@lastframesprites[i].selected = false
@@ -625,8 +627,6 @@ class AnimationCanvas < Sprite
@lastframesprites[i].y = cel[AnimFrame::Y] + 64
@lastframesprites[i].visible = true
@lastframesprites[i].repaint
else
@lastframesprites[i].visible = false
end
else
@lastframesprites[i].visible = false
@@ -799,31 +799,30 @@ class AnimationCanvas < Sprite
def updateInput
cel = currentCel
mousepos = Mouse.getMousePos
if mousepos && pbSpriteHitTest(self, mousepos[0], mousepos[1], false, true)
if Input.trigger?(Input::MOUSELEFT) # Left mouse button
selectedcel = -1
usealpha = (Input.press?(Input::ALT)) ? true : false
PBAnimation::MAX_SPRITES.times do |j|
if pbSpriteHitTest(@celsprites[j], mousepos[0], mousepos[1], usealpha, false)
selectedcel = j
end
if Input.trigger?(Input::MOUSELEFT) && mousepos &&
pbSpriteHitTest(self, mousepos[0], mousepos[1], false, true)
selectedcel = -1
usealpha = (Input.press?(Input::ALT)) ? true : false
PBAnimation::MAX_SPRITES.times do |j|
if pbSpriteHitTest(@celsprites[j], mousepos[0], mousepos[1], usealpha, false)
selectedcel = j
end
if selectedcel < 0
if @animbitmap && addSprite(mousepos[0] - BORDERSIZE, mousepos[1] - BORDERSIZE)
@selecting = true if !self.locked?(@currentcel)
@selectOffsetX = 0
@selectOffsetY = 0
cel = currentCel
invalidate
end
else
@currentcel = selectedcel
end
if selectedcel < 0
if @animbitmap && addSprite(mousepos[0] - BORDERSIZE, mousepos[1] - BORDERSIZE)
@selecting = true if !self.locked?(@currentcel)
@selectOffsetX = 0
@selectOffsetY = 0
cel = currentCel
@selectOffsetX = cel[AnimFrame::X] - mousepos[0] + BORDERSIZE
@selectOffsetY = cel[AnimFrame::Y] - mousepos[1] + BORDERSIZE
invalidate
end
else
@currentcel = selectedcel
@selecting = true if !self.locked?(@currentcel)
cel = currentCel
@selectOffsetX = cel[AnimFrame::X] - mousepos[0] + BORDERSIZE
@selectOffsetY = cel[AnimFrame::Y] - mousepos[1] + BORDERSIZE
invalidate
end
end
currentFrame = getCurrentFrame

View File

@@ -144,10 +144,10 @@ class Button < UIControl
color = Color.new(120, 120, 120)
bitmap.fill_rect(x + 1, y + 1, width - 2, height - 2, color)
ret = Rect.new(x + 1, y + 1, width - 2, height - 2)
if !@captured
bitmap.fill_rect(x + 2, y + 2, width - 4, height - 4, Color.new(0, 0, 0, 0))
else
if @captured
bitmap.fill_rect(x + 2, y + 2, width - 4, height - 4, Color.new(120, 120, 120, 80))
else
bitmap.fill_rect(x + 2, y + 2, width - 4, height - 4, Color.new(0, 0, 0, 0))
end
size = bitmap.text_size(self.label).width
shadowtext(bitmap, x + 4, y, size, height, self.label, @disabled)
@@ -196,10 +196,10 @@ class Checkbox < Button
bitmap.fill_rect(x + 2, y + 2, self.width - 4, self.height - 4, Color.new(0, 0, 0, 0))
bitmap.fill_rect(x + 1, y + 1, width - 2, height - 2, color)
ret = Rect.new(x + 1, y + 1, width - 2, height - 2)
if !@captured
bitmap.fill_rect(x + 2, y + 2, width - 4, height - 4, Color.new(0, 0, 0, 0))
else
if @captured
bitmap.fill_rect(x + 2, y + 2, width - 4, height - 4, Color.new(120, 120, 120, 80))
else
bitmap.fill_rect(x + 2, y + 2, width - 4, height - 4, Color.new(0, 0, 0, 0))
end
if self.checked
shadowtext(bitmap, x, y, 32, 32, "X", @disabled, 1)
@@ -259,7 +259,7 @@ class TextField < UIControl
@frame += 1
@frame %= 20
self.changed = false
self.invalidate if ((@frame % 10) == 0)
self.invalidate if (@frame % 10) == 0
# Moving cursor
if Input.triggerex?(:LEFT) || Input.repeatex?(:LEFT)
if @cursor > 0
@@ -302,10 +302,10 @@ class TextField < UIControl
width -= size
bitmap.fill_rect(x + 1, y + 1, width - 2, height - 2, color)
ret = Rect.new(x + 1, y + 1, width - 2, height - 2)
if !@captured
bitmap.fill_rect(x + 2, y + 2, width - 4, height - 4, Color.new(0, 0, 0, 0))
else
if @captured
bitmap.fill_rect(x + 2, y + 2, width - 4, height - 4, Color.new(120, 120, 120, 80))
else
bitmap.fill_rect(x + 2, y + 2, width - 4, height - 4, Color.new(0, 0, 0, 0))
end
x += 4
textscan = self.text.scan(/./m)
@@ -314,7 +314,7 @@ class TextField < UIControl
@cursor = 0 if @cursor < 0
startpos = @cursor
fromcursor = 0
while (startpos > 0)
while startpos > 0
c = textscan[startpos - 1]
fromcursor += bitmap.text_size(c).width
break if fromcursor > width - 4
@@ -668,7 +668,7 @@ class TextSlider < UIControl
def refresh
bitmap = self.bitmap
if @maxoptionwidth == nil
if @maxoptionwidth.nil?
@options.length.times do |i|
w = self.bitmap.text_size(" " + @options[i] + " ").width
@maxoptionwidth = w if !@maxoptionwidth || @maxoptionwidth < w

View File

@@ -166,15 +166,13 @@ class PointPath
i = 0
@distances.each do |dist|
curdist += dist
if dist > 0.0
if curdist >= distForT
distT = 1.0 - ((curdist - distForT) / dist)
dx = @points[i + 1][0] - @points[i][0]
dy = @points[i + 1][1] - @points[i][1]
ret = [@points[i][0] + (dx * distT),
@points[i][1] + (dy * distT)]
break
end
if dist > 0.0 && curdist >= distForT
distT = 1.0 - ((curdist - distForT) / dist)
dx = @points[i + 1][0] - @points[i][0]
dy = @points[i + 1][1] - @points[i][1]
ret = [@points[i][0] + (dx * distT),
@points[i][1] + (dy * distT)]
break
end
i += 1
end
@@ -295,8 +293,8 @@ def pbDefinePath(canvas)
if Input.trigger?(Input::MOUSELEFT)
4.times do |j|
next if !curve[j].hittest?
if [1, 2].include?(j)
next if !curve[0].visible || !curve[3].visible
if [1, 2].include?(j) && (!curve[0].visible || !curve[3].visible)
next
end
curve[j].visible = true
4.times do |k|
@@ -381,7 +379,7 @@ def pbDefinePath(canvas)
mousepos = Mouse.getMousePos(true)
window.text = (mousepos) ? sprintf("(%d,%d)", mousepos[0], mousepos[1]) : "(??,??)"
end
while !canceled
until canceled
mousepos = Mouse.getMousePos(true)
if mousepos && !pointpath.isEndPoint?(mousepos[0], mousepos[1])
pointpath.addPoint(mousepos[0], mousepos[1])

View File

@@ -91,7 +91,7 @@ def pbConvertAnimToNewFormat(textdata)
next if !textdata[i]
PBAnimation::MAX_SPRITES.times do |j|
next if !textdata[i][j]
needconverting = true if textdata[i][j][AnimFrame::FOCUS] == nil
needconverting = true if textdata[i][j][AnimFrame::FOCUS].nil?
break if needconverting
end
break if needconverting
@@ -101,7 +101,7 @@ def pbConvertAnimToNewFormat(textdata)
next if !textdata[i]
PBAnimation::MAX_SPRITES.times do |j|
next if !textdata[i][j]
textdata[i][j][AnimFrame::PRIORITY] = 1 if textdata[i][j][AnimFrame::PRIORITY] == nil
textdata[i][j][AnimFrame::PRIORITY] = 1 if textdata[i][j][AnimFrame::PRIORITY].nil?
case j
when 0 # User battler
textdata[i][j][AnimFrame::FOCUS] = 2

View File

@@ -707,7 +707,7 @@ def pbCopyFrames(canvas)
dstvalue = sliderwin2.value(2) - 1
length = (endvalue - startvalue) + 1
if length > 0 # Ensure correct overlap handling
if (startvalue < dstvalue)
if startvalue < dstvalue
startvalue += length
dstvalue += length
while length != 0
@@ -1187,5 +1187,5 @@ def pbAnimationEditor
animationEditorMain(animation)
Graphics.resize_screen(Settings::SCREEN_WIDTH, Settings::SCREEN_HEIGHT)
pbSetResizeFactor($PokemonSystem.screensize)
$game_map.autoplay if $game_map
$game_map&.autoplay
end

View File

@@ -829,7 +829,7 @@ end
module MapProperty
def self.set(settingname, oldsetting)
chosenmap = pbListScreen(settingname, MapLister.new(oldsetting ? oldsetting : 0))
chosenmap = pbListScreen(settingname, MapLister.new(oldsetting || 0))
return (chosenmap > 0) ? chosenmap : oldsetting
end
@@ -1285,7 +1285,7 @@ class EvolutionsProperty
ret = nil if ret.empty?
else
params = ChooseNumberParams.new
params.setRange(0, 65535)
params.setRange(0, 65_535)
params.setDefaultValue(value) if value
params.setCancelValue(-1)
ret = pbMessageChooseNumber(_INTL("Choose a parameter."), params)

View File

@@ -22,7 +22,7 @@ module DebugMenuCommands
def self.hasFunction?(option, function)
option_hash = @@commands[option]
return option_hash && option_hash.keys.include?(function)
return option_hash&.has_key?(function)
end
def self.getFunction(option, function)

View File

@@ -21,8 +21,8 @@ def pbWarpToMap
next if !map.passableStrict?(x, y, 0, $game_player)
blocked = false
map.events.values.each do |event|
if event.at_coordinate?(x, y) && !event.through
blocked = true if event.character_name != ""
if event.at_coordinate?(x, y) && !event.through && event.character_name != ""
blocked = true
end
end
next if blocked
@@ -101,7 +101,7 @@ class SpriteWindow_DebugVariables < Window_DrawableCommand
status = $game_variables[index + 1].to_s
status = "\"__\"" if nil_or_empty?(status)
end
name = '' if name == nil
name = '' if name.nil?
id_text = sprintf("%04d:", index + 1)
rect = drawCursor(index, rect)
totalWidth = rect.width
@@ -117,11 +117,11 @@ end
def pbDebugSetVariable(id, diff)
$game_variables[id] = 0 if $game_variables[id] == nil
$game_variables[id] = 0 if $game_variables[id].nil?
if $game_variables[id].is_a?(Numeric)
pbPlayCursorSE
$game_variables[id] = [$game_variables[id] + diff, 99999999].min
$game_variables[id] = [$game_variables[id], -99999999].max
$game_variables[id] = [$game_variables[id] + diff, 99_999_999].min
$game_variables[id] = [$game_variables[id], -99_999_999].max
$game_map.need_refresh = true
end
end
@@ -135,8 +135,8 @@ def pbDebugVariableScreen(id)
params.setMaxDigits(8)
params.setNegativesAllowed(true)
value = pbMessageChooseNumber(_INTL("Set variable {1}.", id), params)
$game_variables[id] = [value, 99999999].min
$game_variables[id] = [$game_variables[id], -99999999].max
$game_variables[id] = [value, 99_999_999].min
$game_variables[id] = [$game_variables[id], -99_999_999].max
$game_map.need_refresh = true
when String
value = pbMessageFreeText(_INTL("Set variable {1}.", id),
@@ -623,7 +623,7 @@ def pbImportAllAnimations
Graphics.update
audios = []
files = Dir.glob(folder + "/*.*")
%w[wav ogg mid wma].each { |ext| # mp3
["wav", "ogg", "mid", "wma"].each { |ext| # mp3
upext = ext.upcase
audios.concat(files.find_all { |f| f[f.length - 3, 3] == ext })
audios.concat(files.find_all { |f| f[f.length - 3, 3] == upext })
@@ -632,7 +632,7 @@ def pbImportAllAnimations
pbSafeCopyFile(audio, RTP.getAudioPath("Audio/SE/Anim/" + File.basename(audio)), "Audio/SE/Anim/" + File.basename(audio))
end
images = []
%w[png gif].each { |ext| # jpg jpeg bmp
["png", "gif"].each { |ext| # jpg jpeg bmp
upext = ext.upcase
images.concat(files.find_all { |f| f[f.length - 3, 3] == ext })
images.concat(files.find_all { |f| f[f.length - 3, 3] == upext })
@@ -642,26 +642,24 @@ def pbImportAllAnimations
end
Dir.glob(folder + "/*.anm") { |f|
textdata = loadBase64Anim(IO.read(f)) rescue nil
if textdata && textdata.is_a?(PBAnimation)
if textdata.is_a?(PBAnimation)
index = pbAllocateAnimation(animations, textdata.name)
missingFiles = []
textdata.name = File.basename(folder) if textdata.name == ""
textdata.id = -1 # This is not an RPG Maker XP animation
pbConvertAnimToNewFormat(textdata)
if textdata.graphic && textdata.graphic != ""
if !safeExists?(folder + "/" + textdata.graphic) &&
!FileTest.image_exist?("Graphics/Animations/" + textdata.graphic)
textdata.graphic = ""
missingFiles.push(textdata.graphic)
end
if textdata.graphic && textdata.graphic != "" &&
!safeExists?(folder + "/" + textdata.graphic) &&
!FileTest.image_exist?("Graphics/Animations/" + textdata.graphic)
textdata.graphic = ""
missingFiles.push(textdata.graphic)
end
textdata.timing.each do |timing|
if timing.name && timing.name != ""
if !safeExists?(folder + "/" + timing.name) &&
!FileTest.audio_exist?("Audio/SE/Anim/" + timing.name)
timing.name = ""
missingFiles.push(timing.name)
end
if timing.name && timing.name != "" &&
!safeExists?(folder + "/" + timing.name) &&
!FileTest.audio_exist?("Audio/SE/Anim/" + timing.name)
timing.name = ""
missingFiles.push(timing.name)
end
end
animations[index] = textdata

View File

@@ -22,7 +22,7 @@ module PokemonDebugMenuCommands
def self.hasFunction?(option, function)
option_hash = @@commands[option]
return option_hash && option_hash.keys.include?(function)
return option_hash&.has_key?(function)
end
def self.getFunction(option, function)
@@ -1029,7 +1029,7 @@ PokemonDebugMenuCommands.register("ownership", {
pkmn.owner.id = $player.make_foreign_ID
when 4 # Set foreign ID
params = ChooseNumberParams.new
params.setRange(0, 65535)
params.setRange(0, 65_535)
params.setDefaultValue(pkmn.owner.public_id)
val = pbMessageChooseNumber(
_INTL("Set the new ID (max. 65535)."), params
@@ -1129,11 +1129,11 @@ PokemonDebugMenuCommands.register("shadow_pkmn", {
break if cmd < 0
case cmd
when 0 # Make Shadow
if !pkmn.shadowPokemon?
if pkmn.shadowPokemon?
screen.pbDisplay(_INTL("{1} is already a Shadow Pokémon.", pkmn.name))
else
pkmn.makeShadow
screen.pbRefreshSingle(pkmnid)
else
screen.pbDisplay(_INTL("{1} is already a Shadow Pokémon.", pkmn.name))
end
when 1 # Set heart gauge
if pkmn.shadowPokemon?

View File

@@ -44,7 +44,7 @@ module BattleDebugMenuCommands
def self.hasFunction?(option, function)
option_hash = @@commands[option]
return option_hash && option_hash.keys.include?(function)
return option_hash&.has_key?(function)
end
def self.getFunction(option, function)

View File

@@ -32,7 +32,7 @@ module BattlePokemonDebugMenuCommands
def self.hasFunction?(option, function)
option_hash = @@commands[option]
return option_hash && option_hash.keys.include?(function)
return option_hash&.has_key?(function)
end
def self.getFunction(option, function)
@@ -241,7 +241,7 @@ BattlePokemonDebugMenuCommands.register("set_level", {
if level != pkmn.level
pkmn.level = level
pkmn.calc_stats
battler.pbUpdate if battler
battler&.pbUpdate
end
}
})
@@ -315,7 +315,7 @@ BattlePokemonDebugMenuCommands.register("hidden_values", {
if f != pkmn.ev[ev_id[cmd2]]
pkmn.ev[ev_id[cmd2]] = f
pkmn.calc_stats
battler.pbUpdate if battler
battler&.pbUpdate
end
else # (Max) Randomise all
evTotalTarget = Pokemon::EV_LIMIT
@@ -334,7 +334,7 @@ BattlePokemonDebugMenuCommands.register("hidden_values", {
evTotalTarget -= addVal
end
pkmn.calc_stats
battler.pbUpdate if battler
battler&.pbUpdate
end
end
when 1 # Set IVs
@@ -365,12 +365,12 @@ BattlePokemonDebugMenuCommands.register("hidden_values", {
if f != pkmn.iv[iv_id[cmd2]]
pkmn.iv[iv_id[cmd2]] = f
pkmn.calc_stats
battler.pbUpdate if battler
battler&.pbUpdate
end
else # Randomise all
GameData::Stat.each_main { |s| pkmn.iv[s.id] = rand(Pokemon::IV_STAT_LIMIT + 1) }
pkmn.calc_stats
battler.pbUpdate if battler
battler&.pbUpdate
end
end
end
@@ -467,7 +467,7 @@ BattlePokemonDebugMenuCommands.register("teach_move", {
next
end
pkmn.learn_move(new_move)
battler.moves.push(Battle::Move.from_pokemon_move(self, pkmn.moves.last)) if battler
battler&.moves&.push(Battle::Move.from_pokemon_move(self, pkmn.moves.last))
pbMessage("\\ts[]" + _INTL("{1} learned {2}!", pkmn.name, move_name))
}
})
@@ -492,7 +492,7 @@ BattlePokemonDebugMenuCommands.register("forget_move", {
next if cmd < 0
old_move_name = pkmn.moves[move_indices[cmd]].name
pkmn.forget_move_at_index(move_indices[cmd])
battler.moves.delete_at(move_indices[cmd]) if battler
battler&.moves&.delete_at(move_indices[cmd])
pbMessage("\\ts[]" + _INTL("{1} forgot {2}.", pkmn.name, old_move_name))
}
})
@@ -688,7 +688,7 @@ BattlePokemonDebugMenuCommands.register("set_nature", {
elsif cmd == commands.length - 1 # Reset
pkmn.nature = nil
end
battler.pbUpdate if battler
battler&.pbUpdate
end
}
})

View File

@@ -119,7 +119,7 @@ module Battle::DebugVariables
PBEffects::Unburden => { name: "Self lost its item (for Unburden)", default: false },
PBEffects::Uproar => { name: "Uproar number of rounds remaining", default: 0 },
PBEffects::WaterSport => { name: "Used Water Sport (Gen 5 and older)", default: false },
PBEffects::WeightChange => { name: "Weight change +0.1*x kg", default: 0, min: -99999, max: 99999 },
PBEffects::WeightChange => { name: "Weight change +0.1*x kg", default: 0, min: -99_999, max: 99_999 },
PBEffects::Yawn => { name: "Yawn rounds remaining until falling asleep", default: 0 }
}
@@ -421,7 +421,7 @@ class Battle::DebugSetEffects
@window.refresh if update_input_for_integer(effect, variable_data[:default], variable_data)
elsif variable_data[:default] == -1
@window.refresh if update_input_for_battler_index(effect, variable_data)
elsif variable_data[:default] == nil
elsif variable_data[:default].nil?
case variable_data[:type]
when :move
@window.refresh if update_input_for_move(effect, variable_data)

View File

@@ -132,7 +132,7 @@ class GraphicsLister
end
def dispose
@sprite.bitmap.dispose if @sprite.bitmap
@sprite.bitmap&.dispose
@sprite.dispose
end
@@ -320,7 +320,7 @@ class MapLister
end
def dispose
@sprite.bitmap.dispose if @sprite.bitmap
@sprite.bitmap&.dispose
@sprite.dispose
end
@@ -344,14 +344,12 @@ class MapLister
end
def value(index)
if @addGlobalOffset == 1
return 0 if index == 0
end
return 0 if @addGlobalOffset == 1 && index == 0
return (index < 0) ? -1 : @maps[index - @addGlobalOffset][0]
end
def refresh(index)
@sprite.bitmap.dispose if @sprite.bitmap
@sprite.bitmap&.dispose
return if index < 0
return if index == 0 && @addGlobalOffset == 1
@sprite.bitmap = createMinimap(@maps[index - @addGlobalOffset][0])
@@ -426,7 +424,7 @@ class ItemLister
end
def dispose
@sprite.bitmap.dispose if @sprite.bitmap
@sprite.bitmap&.dispose
@sprite.dispose
end
@@ -487,7 +485,7 @@ class TrainerTypeLister
end
def dispose
@sprite.bitmap.dispose if @sprite.bitmap
@sprite.bitmap&.dispose
@sprite.dispose
end
@@ -529,7 +527,7 @@ class TrainerTypeLister
end
def refresh(index)
@sprite.bitmap.dispose if @sprite.bitmap
@sprite.bitmap&.dispose
return if index < 0
begin
if @ids[index].is_a?(Symbol)
@@ -566,7 +564,7 @@ class TrainerBattleLister
end
def dispose
@sprite.bitmap.dispose if @sprite.bitmap
@sprite.bitmap&.dispose
@sprite.dispose
@pkmnList.dispose
end
@@ -629,7 +627,7 @@ class TrainerBattleLister
def refresh(index)
# Refresh trainer sprite
@sprite.bitmap.dispose if @sprite.bitmap
@sprite.bitmap&.dispose
return if index < 0
begin
if @ids[index].is_a?(Array)