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

@@ -4,8 +4,9 @@ module Battle::CatchAndStoreMixin
#=============================================================================
def pbStorePokemon(pkmn)
# Nickname the Pokémon (unless it's a Shadow Pokémon)
if !pkmn.shadowPokemon? && $PokemonSystem.givenicknames == 0
if pbDisplayConfirm(_INTL("Would you like to give a nickname to {1}?", pkmn.name))
if !pkmn.shadowPokemon?
if $PokemonSystem.givenicknames == 0 &&
pbDisplayConfirm(_INTL("Would you like to give a nickname to {1}?", pkmn.name))
nickname = @scene.pbNameEntry(_INTL("{1}'s nickname?", pkmn.speciesName), pkmn)
pkmn.name = nickname
end
@@ -166,7 +167,7 @@ module Battle::CatchAndStoreMixin
# Definite capture, no need to perform randomness checks
return 4 if x >= 255 || Battle::PokeBallEffects.isUnconditional?(ball, self, battler)
# Second half of the shakes calculation
y = (65536 / ((255.0 / x)**0.1875)).floor
y = (65_536 / ((255.0 / x)**0.1875)).floor
# Critical capture check
if Settings::ENABLE_CRITICAL_CAPTURES
dex_modifier = 0
@@ -187,7 +188,7 @@ module Battle::CatchAndStoreMixin
# Calculate the number of shakes
if c > 0 && pbRandom(256) < c
@criticalCapture = true
return 4 if pbRandom(65536) < y
return 4 if pbRandom(65_536) < y
return 0
end
end
@@ -195,7 +196,7 @@ module Battle::CatchAndStoreMixin
numShakes = 0
4.times do |i|
break if numShakes < i
numShakes += 1 if pbRandom(65536) < y
numShakes += 1 if pbRandom(65_536) < y
end
return numShakes
end

View File

@@ -494,7 +494,7 @@ class PBAnimation < Array
when 0 # Play SE
if i.name && i.name != ""
pbSEPlay("Anim/" + i.name, i.volume, i.pitch)
elsif user && user.pokemon
elsif user&.pokemon
name = GameData::Species.cry_filename_from_pokemon(user.pokemon)
pbSEPlay(name, i.volume, i.pitch) if name
end
@@ -517,16 +517,16 @@ class PBAnimation < Array
bgColor.opacity = i.opacity || 0
end
when 2 # Move/recolour background graphic
if bgGraphic.bitmap != nil
oldbg[0] = bgGraphic.ox || 0
oldbg[1] = bgGraphic.oy || 0
oldbg[2] = bgGraphic.opacity || 0
oldbg[3] = bgGraphic.color.clone || Color.new(0, 0, 0, 0)
else
if bgGraphic.bitmap.nil?
oldbg[0] = 0
oldbg[1] = 0
oldbg[2] = bgColor.opacity || 0
oldbg[3] = bgColor.color.clone || Color.new(0, 0, 0, 0)
else
oldbg[0] = bgGraphic.ox || 0
oldbg[1] = bgGraphic.oy || 0
oldbg[2] = bgGraphic.opacity || 0
oldbg[3] = bgGraphic.color.clone || Color.new(0, 0, 0, 0)
end
when 3 # Set foreground graphic (immediate)
if i.name && i.name != ""
@@ -543,16 +543,16 @@ class PBAnimation < Array
foColor.opacity = i.opacity || 0
end
when 4 # Move/recolour foreground graphic
if foGraphic.bitmap != nil
oldfo[0] = foGraphic.ox || 0
oldfo[1] = foGraphic.oy || 0
oldfo[2] = foGraphic.opacity || 0
oldfo[3] = foGraphic.color.clone || Color.new(0, 0, 0, 0)
else
if foGraphic.bitmap.nil?
oldfo[0] = 0
oldfo[1] = 0
oldfo[2] = foColor.opacity || 0
oldfo[3] = foColor.color.clone || Color.new(0, 0, 0, 0)
else
oldfo[0] = foGraphic.ox || 0
oldfo[1] = foGraphic.oy || 0
oldfo[2] = foGraphic.opacity || 0
oldfo[3] = foGraphic.color.clone || Color.new(0, 0, 0, 0)
end
end
end
@@ -562,7 +562,14 @@ class PBAnimation < Array
next if !i.duration || i.duration <= 0
next if frame < i.frame || frame > i.frame + i.duration
fraction = (frame - i.frame).to_f / i.duration
if bgGraphic.bitmap != nil
if bgGraphic.bitmap.nil?
bgColor.opacity = oldbg[2] + ((i.opacity - oldbg[2]) * fraction) if i.opacity != nil
cr = (i.colorRed != nil) ? oldbg[3].red + ((i.colorRed - oldbg[3].red) * fraction) : oldbg[3].red
cg = (i.colorGreen != nil) ? oldbg[3].green + ((i.colorGreen - oldbg[3].green) * fraction) : oldbg[3].green
cb = (i.colorBlue != nil) ? oldbg[3].blue + ((i.colorBlue - oldbg[3].blue) * fraction) : oldbg[3].blue
ca = (i.colorAlpha != nil) ? oldbg[3].alpha + ((i.colorAlpha - oldbg[3].alpha) * fraction) : oldbg[3].alpha
bgColor.color = Color.new(cr, cg, cb, ca)
else
bgGraphic.ox = oldbg[0] - ((i.bgX - oldbg[0]) * fraction) if i.bgX != nil
bgGraphic.oy = oldbg[1] - ((i.bgY - oldbg[1]) * fraction) if i.bgY != nil
bgGraphic.opacity = oldbg[2] + ((i.opacity - oldbg[2]) * fraction) if i.opacity != nil
@@ -571,19 +578,19 @@ class PBAnimation < Array
cb = (i.colorBlue != nil) ? oldbg[3].blue + ((i.colorBlue - oldbg[3].blue) * fraction) : oldbg[3].blue
ca = (i.colorAlpha != nil) ? oldbg[3].alpha + ((i.colorAlpha - oldbg[3].alpha) * fraction) : oldbg[3].alpha
bgGraphic.color = Color.new(cr, cg, cb, ca)
else
bgColor.opacity = oldbg[2] + ((i.opacity - oldbg[2]) * fraction) if i.opacity != nil
cr = (i.colorRed != nil) ? oldbg[3].red + ((i.colorRed - oldbg[3].red) * fraction) : oldbg[3].red
cg = (i.colorGreen != nil) ? oldbg[3].green + ((i.colorGreen - oldbg[3].green) * fraction) : oldbg[3].green
cb = (i.colorBlue != nil) ? oldbg[3].blue + ((i.colorBlue - oldbg[3].blue) * fraction) : oldbg[3].blue
ca = (i.colorAlpha != nil) ? oldbg[3].alpha + ((i.colorAlpha - oldbg[3].alpha) * fraction) : oldbg[3].alpha
bgColor.color = Color.new(cr, cg, cb, ca)
end
when 4
next if !i.duration || i.duration <= 0
next if frame < i.frame || frame > i.frame + i.duration
fraction = (frame - i.frame).to_f / i.duration
if foGraphic.bitmap != nil
if foGraphic.bitmap.nil?
foColor.opacity = oldfo[2] + ((i.opacity - oldfo[2]) * fraction) if i.opacity != nil
cr = (i.colorRed != nil) ? oldfo[3].red + ((i.colorRed - oldfo[3].red) * fraction) : oldfo[3].red
cg = (i.colorGreen != nil) ? oldfo[3].green + ((i.colorGreen - oldfo[3].green) * fraction) : oldfo[3].green
cb = (i.colorBlue != nil) ? oldfo[3].blue + ((i.colorBlue - oldfo[3].blue) * fraction) : oldfo[3].blue
ca = (i.colorAlpha != nil) ? oldfo[3].alpha + ((i.colorAlpha - oldfo[3].alpha) * fraction) : oldfo[3].alpha
foColor.color = Color.new(cr, cg, cb, ca)
else
foGraphic.ox = oldfo[0] - ((i.bgX - oldfo[0]) * fraction) if i.bgX != nil
foGraphic.oy = oldfo[1] - ((i.bgY - oldfo[1]) * fraction) if i.bgY != nil
foGraphic.opacity = oldfo[2] + ((i.opacity - oldfo[2]) * fraction) if i.opacity != nil
@@ -592,13 +599,6 @@ class PBAnimation < Array
cb = (i.colorBlue != nil) ? oldfo[3].blue + ((i.colorBlue - oldfo[3].blue) * fraction) : oldfo[3].blue
ca = (i.colorAlpha != nil) ? oldfo[3].alpha + ((i.colorAlpha - oldfo[3].alpha) * fraction) : oldfo[3].alpha
foGraphic.color = Color.new(cr, cg, cb, ca)
else
foColor.opacity = oldfo[2] + ((i.opacity - oldfo[2]) * fraction) if i.opacity != nil
cr = (i.colorRed != nil) ? oldfo[3].red + ((i.colorRed - oldfo[3].red) * fraction) : oldfo[3].red
cg = (i.colorGreen != nil) ? oldfo[3].green + ((i.colorGreen - oldfo[3].green) * fraction) : oldfo[3].green
cb = (i.colorBlue != nil) ? oldfo[3].blue + ((i.colorBlue - oldfo[3].blue) * fraction) : oldfo[3].blue
ca = (i.colorAlpha != nil) ? oldfo[3].alpha + ((i.colorAlpha - oldfo[3].alpha) * fraction) : oldfo[3].alpha
foColor.color = Color.new(cr, cg, cb, ca)
end
end
end
@@ -700,10 +700,10 @@ class PBAnimationPlayerX
@user = (oppMove) ? target : user # Just used for playing user's cry
@usersprite = (user) ? scene.sprites["pokemon_#{user.index}"] : nil
@targetsprite = (target) ? scene.sprites["pokemon_#{target.index}"] : nil
@userbitmap = (@usersprite && @usersprite.bitmap) ? @usersprite.bitmap : nil # not to be disposed
@targetbitmap = (@targetsprite && @targetsprite.bitmap) ? @targetsprite.bitmap : nil # not to be disposed
@userbitmap = @usersprite&.bitmap # not to be disposed
@targetbitmap = @targetsprite&.bitmap # not to be disposed
@scene = scene
@viewport = (scene) ? scene.viewport : nil
@viewport = scene&.viewport
@inEditor = inEditor
@looping = false
@animbitmap = nil # Animation sheet graphic
@@ -761,9 +761,9 @@ class PBAnimationPlayerX
end
def dispose
@animbitmap.dispose if @animbitmap
@animbitmap&.dispose
(2...MAX_SPRITES).each do |i|
@animsprites[i].dispose if @animsprites[i]
@animsprites[i]&.dispose
end
@bgGraphic.dispose
@bgColor.dispose
@@ -792,7 +792,7 @@ class PBAnimationPlayerX
if animFrame >= @animation.length
@frame = (@looping) ? 0 : -1
if @frame < 0
@animbitmap.dispose if @animbitmap
@animbitmap&.dispose
@animbitmap = nil
return
end

View File

@@ -1179,8 +1179,8 @@ Battle::AbilityEffects::AccuracyCalcFromTarget.add(:UNAWARE,
Battle::AbilityEffects::AccuracyCalcFromTarget.add(:WONDERSKIN,
proc { |ability, mods, user, target, move, type|
if move.statusMove? && user.opposes?(target)
mods[:base_accuracy] = 50 if mods[:base_accuracy] > 50
if move.statusMove? && user.opposes?(target) && mods[:base_accuracy] > 50
mods[:base_accuracy] = 50
end
}
)

View File

@@ -1421,11 +1421,10 @@ Battle::ItemEffects::OnBeingHit.add(:STICKYBARB,
user.item = target.item
target.item = nil
target.effects[PBEffects::Unburden] = true if target.hasActiveAbility?(:UNBURDEN)
if battle.wildBattle? && !user.opposes?
if !user.initialItem && user.item == target.initialItem
user.setInitialItem(user.item)
target.setInitialItem(nil)
end
if battle.wildBattle? && !user.opposes? &&
!user.initialItem && user.item == target.initialItem
user.setInitialItem(user.item)
target.setInitialItem(nil)
end
battle.pbDisplay(_INTL("{1}'s {2} was transferred to {3}!",
target.pbThis, user.itemName, user.pbThis(true)))