More Rubocop changes

This commit is contained in:
Maruno17
2022-02-13 00:57:54 +00:00
parent cca5989746
commit f68e699cc9
108 changed files with 708 additions and 808 deletions

View File

@@ -266,11 +266,9 @@ class Battle
if opposes?(idxBattler)
return [] if !@items
return @items[pbGetOwnerIndexFromBattlerIndex(idxBattler)]
else
return [] if !@ally_items
return @ally_items[pbGetOwnerIndexFromBattlerIndex(idxBattler)]
end
return []
return [] if !@ally_items
return @ally_items[pbGetOwnerIndexFromBattlerIndex(idxBattler)]
end
# Returns whether the battler in position idxBattler is owned by the same

View File

@@ -60,10 +60,11 @@ class Battle
end
sideCounts.each_with_index do |_count, i|
if !requireds[i] || requireds[i] == 0
if side == 0
case side
when 0
raise _INTL("Player-side trainer {1} has no battler position for their Pokémon to go (trying {2}v{3} battle)",
i + 1, @sideSizes[0], @sideSizes[1])
elsif side == 1
when 1
raise _INTL("Opposing trainer {1} has no battler position for their Pokémon to go (trying {2}v{3} battle)",
i + 1, @sideSizes[0], @sideSizes[1])
end

View File

@@ -431,7 +431,7 @@ class Battle::Battler
# NOTE: If a multi-hit move becomes disabled partway through doing those
# hits (e.g. by Cursed Body), the rest of the hits continue as
# normal.
break if !targets.any? { |t| !t.fainted? } # All targets are fainted
break if targets.none? { |t| !t.fainted? } # All targets are fainted
end
# Battle Arena only - attack is successful
@battle.successStates[user.index].useState = 2

View File

@@ -462,7 +462,7 @@ class Battle::Move::UserLosesHalfOfTotalHPExplosive < Battle::Move
def pbMoveFailed?(user, targets)
if !@battle.moldBreaker
bearer = @battle.pbCheckGlobalAbility(:DAMP)
if bearer != nil
if bearer
@battle.pbShowAbilitySplash(bearer)
if Battle::Scene::USE_ABILITY_SPLASH
@battle.pbDisplay(_INTL("{1} cannot use {2}!", user.pbThis, @name))
@@ -494,7 +494,7 @@ class Battle::Move::UserFaintsExplosive < Battle::Move
def pbMoveFailed?(user, targets)
if !@battle.moldBreaker
bearer = @battle.pbCheckGlobalAbility(:DAMP)
if bearer != nil
if bearer
@battle.pbShowAbilitySplash(bearer)
if Battle::Scene::USE_ABILITY_SPLASH
@battle.pbDisplay(_INTL("{1} cannot use {2}!", user.pbThis, @name))

View File

@@ -762,7 +762,7 @@ class Battle::Move::UseLastMoveUsedByTarget < Battle::Move
def pbFailsAgainstTarget?(user, target, show_message)
if !target.lastRegularMoveUsed ||
!GameData::Move.get(target.lastRegularMoveUsed).flags.any? { |f| f[/^CanMirrorMove$/i] }
GameData::Move.get(target.lastRegularMoveUsed).flags.none? { |f| f[/^CanMirrorMove$/i] }
@battle.pbDisplay(_INTL("The mirror move failed!")) if show_message
return true
end

View File

@@ -88,11 +88,10 @@ class Battle::Scene
shouldCompact = false
@animations.each_with_index do |a, i|
a.update
if a.animDone?
a.dispose
@animations[i] = nil
shouldCompact = true
end
next if !a.animDone?
a.dispose
@animations[i] = nil
shouldCompact = true
end
@animations.compact! if shouldCompact
end

View File

@@ -195,8 +195,8 @@ class Battle::Scene
# Set Bag starting positions
oldLastPocket = $bag.last_viewed_pocket
oldChoices = $bag.last_pocket_selections.clone
$bag.last_viewed_pocket = @bagLastPocket if @bagLastPocket != nil
$bag.last_pocket_selections = @bagChoices if @bagChoices != nil
$bag.last_viewed_pocket = @bagLastPocket if @bagLastPocket
$bag.last_pocket_selections = @bagChoices if @bagChoices
# Start Bag screen
itemScene = PokemonBag_Scene.new
itemScene.pbStartScene($bag, true,

View File

@@ -137,7 +137,7 @@ class Battle::Scene
a[2] = true if a[1].animDone?
end
pbUpdate
if !inPartyAnimation? && !sendOutAnims.any? { |a| !a[2] }
if !inPartyAnimation? && sendOutAnims.none? { |a| !a[2] }
break
end
end
@@ -515,7 +515,7 @@ class Battle::Scene
return if !animations
animations.each do |a|
next if !a || a.name != "Common:" + animName
pbAnimationCore(a, user, (target != nil) ? target : user)
pbAnimationCore(a, user, target || user)
return
end
end

View File

@@ -174,9 +174,7 @@ class Battle::Scene::CommandMenu < Battle::Scene::MenuBase
@msgBox.text = value[0]
return if USE_GRAPHICS
commands = []
(1..4).each do |i|
commands.push(value[i]) if value[i] && value[i] != nil
end
(1..4).each { |i| commands.push(value[i]) if value[i] }
@cmdWindow.commands = commands
end

View File

@@ -1748,7 +1748,7 @@ class Battle::AI
score -= 40
if skill >= PBTrainerAI.highSkill
score -= 100 if !target.lastRegularMoveUsed ||
!GameData::Move.get(target.lastRegularMoveUsed).flags.any? { |f| f[/^CanMirrorMove$/i] }
GameData::Move.get(target.lastRegularMoveUsed).flags.none? { |f| f[/^CanMirrorMove$/i] }
end
#---------------------------------------------------------------------------
when "UseLastMoveUsed"

View File

@@ -287,58 +287,46 @@ class PBAnimTiming
when 1
text = sprintf("[%d] Set BG: \"%s\"", @frame + 1, name)
text += sprintf(" (color=%s,%s,%s,%s)",
(@colorRed != nil) ? @colorRed.to_i : "-",
(@colorGreen != nil) ? @colorGreen.to_i : "-",
(@colorBlue != nil) ? @colorBlue.to_i : "-",
(@colorAlpha != nil) ? @colorAlpha.to_i : "-")
text += sprintf(" (opacity=%s)", @opacity.to_i)
text += sprintf(" (coords=%s,%s)",
(@bgX != nil) ? @bgX : "-",
(@bgY != nil) ? @bgY : "-")
@colorRed || "-",
@colorGreen || "-",
@colorBlue || "-",
@colorAlpha || "-")
text += sprintf(" (opacity=%d)", @opacity)
text += sprintf(" (coords=%s,%s)", @bgX || "-", @bgY || "-")
return text
when 2
text = sprintf("[%d] Change BG: @%d", @frame + 1, duration)
if @colorRed != nil || @colorGreen != nil || @colorBlue != nil || @colorAlpha != nil
if @colorRed || @colorGreen || @colorBlue || @colorAlpha
text += sprintf(" (color=%s,%s,%s,%s)",
(@colorRed != nil) ? @colorRed.to_i : "-",
(@colorGreen != nil) ? @colorGreen.to_i : "-",
(@colorBlue != nil) ? @colorBlue.to_i : "-",
(@colorAlpha != nil) ? @colorAlpha.to_i : "-")
end
text += sprintf(" (opacity=%s)", @opacity.to_i) if @opacity != nil
if @bgX != nil || @bgY != nil
text += sprintf(" (coords=%s,%s)",
(@bgX != nil) ? @bgX : "-",
(@bgY != nil) ? @bgY : "-")
@colorRed || "-",
@colorGreen || "-",
@colorBlue || "-",
@colorAlpha || "-")
end
text += sprintf(" (opacity=%d)", @opacity) if @opacity
text += sprintf(" (coords=%s,%s)", @bgX || "-", @bgY || "-") if @bgX || @bgY
return text
when 3
text = sprintf("[%d] Set FG: \"%s\"", @frame + 1, name)
text += sprintf(" (color=%s,%s,%s,%s)",
(@colorRed != nil) ? @colorRed.to_i : "-",
(@colorGreen != nil) ? @colorGreen.to_i : "-",
(@colorBlue != nil) ? @colorBlue.to_i : "-",
(@colorAlpha != nil) ? @colorAlpha.to_i : "-")
text += sprintf(" (opacity=%s)", @opacity.to_i)
text += sprintf(" (coords=%s,%s)",
(@bgX != nil) ? @bgX : "-",
(@bgY != nil) ? @bgY : "-")
@colorRed || "-",
@colorGreen | "-",
@colorBlue || "-",
@colorAlpha || "-")
text += sprintf(" (opacity=%d)", @opacity)
text += sprintf(" (coords=%s,%s)", @bgX || "-", @bgY || "-")
return text
when 4
text = sprintf("[%d] Change FG: @%d", @frame + 1, duration)
if @colorRed != nil || @colorGreen != nil || @colorBlue != nil || @colorAlpha != nil
if @colorRed || @colorGreen || @colorBlue || @colorAlpha
text += sprintf(" (color=%s,%s,%s,%s)",
(@colorRed != nil) ? @colorRed.to_i : "-",
(@colorGreen != nil) ? @colorGreen.to_i : "-",
(@colorBlue != nil) ? @colorBlue.to_i : "-",
(@colorAlpha != nil) ? @colorAlpha.to_i : "-")
end
text += sprintf(" (opacity=%s)", @opacity.to_i) if @opacity != nil
if @bgX != nil || @bgY != nil
text += sprintf(" (coords=%s,%s)",
(@bgX != nil) ? @bgX : "-",
(@bgY != nil) ? @bgY : "-")
@colorRed || "-",
@colorGreen || "-",
@colorBlue || "-",
@colorAlpha || "-")
end
text += sprintf(" (opacity=%d)", @opacity) if @opacity
text += sprintf(" (coords=%s,%s)", @bgX || "-", @bgY || "-") if @bgX || @bgY
return text
end
return ""
@@ -563,20 +551,20 @@ class PBAnimation < Array
next if frame < i.frame || frame > i.frame + i.duration
fraction = (frame - i.frame).to_f / i.duration
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.opacity = oldbg[2] + ((i.opacity - oldbg[2]) * fraction) if i.opacity
cr = (i.colorRed) ? oldbg[3].red + ((i.colorRed - oldbg[3].red) * fraction) : oldbg[3].red
cg = (i.colorGreen) ? oldbg[3].green + ((i.colorGreen - oldbg[3].green) * fraction) : oldbg[3].green
cb = (i.colorBlue) ? oldbg[3].blue + ((i.colorBlue - oldbg[3].blue) * fraction) : oldbg[3].blue
ca = (i.colorAlpha) ? 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
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
bgGraphic.ox = oldbg[0] - ((i.bgX - oldbg[0]) * fraction) if i.bgX
bgGraphic.oy = oldbg[1] - ((i.bgY - oldbg[1]) * fraction) if i.bgY
bgGraphic.opacity = oldbg[2] + ((i.opacity - oldbg[2]) * fraction) if i.opacity
cr = (i.colorRed) ? oldbg[3].red + ((i.colorRed - oldbg[3].red) * fraction) : oldbg[3].red
cg = (i.colorGreen) ? oldbg[3].green + ((i.colorGreen - oldbg[3].green) * fraction) : oldbg[3].green
cb = (i.colorBlue) ? oldbg[3].blue + ((i.colorBlue - oldbg[3].blue) * fraction) : oldbg[3].blue
ca = (i.colorAlpha) ? oldbg[3].alpha + ((i.colorAlpha - oldbg[3].alpha) * fraction) : oldbg[3].alpha
bgGraphic.color = Color.new(cr, cg, cb, ca)
end
when 4
@@ -584,20 +572,20 @@ class PBAnimation < Array
next if frame < i.frame || frame > i.frame + i.duration
fraction = (frame - i.frame).to_f / i.duration
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.opacity = oldfo[2] + ((i.opacity - oldfo[2]) * fraction) if i.opacity
cr = (i.colorRed) ? oldfo[3].red + ((i.colorRed - oldfo[3].red) * fraction) : oldfo[3].red
cg = (i.colorGreen) ? oldfo[3].green + ((i.colorGreen - oldfo[3].green) * fraction) : oldfo[3].green
cb = (i.colorBlue) ? oldfo[3].blue + ((i.colorBlue - oldfo[3].blue) * fraction) : oldfo[3].blue
ca = (i.colorAlpha) ? 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
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
foGraphic.ox = oldfo[0] - ((i.bgX - oldfo[0]) * fraction) if i.bgX
foGraphic.oy = oldfo[1] - ((i.bgY - oldfo[1]) * fraction) if i.bgY
foGraphic.opacity = oldfo[2] + ((i.opacity - oldfo[2]) * fraction) if i.opacity
cr = (i.colorRed) ? oldfo[3].red + ((i.colorRed - oldfo[3].red) * fraction) : oldfo[3].red
cg = (i.colorGreen) ? oldfo[3].green + ((i.colorGreen - oldfo[3].green) * fraction) : oldfo[3].green
cb = (i.colorBlue) ? oldfo[3].blue + ((i.colorBlue - oldfo[3].blue) * fraction) : oldfo[3].blue
ca = (i.colorAlpha) ? oldfo[3].alpha + ((i.colorAlpha - oldfo[3].alpha) * fraction) : oldfo[3].alpha
foGraphic.color = Color.new(cr, cg, cb, ca)
end
end

View File

@@ -68,7 +68,7 @@ module Battle::AbilityEffects
def self.trigger(hash, *args, ret: false)
new_ret = hash.trigger(*args)
return (new_ret != nil) ? new_ret : ret
return (!new_ret.nil?) ? new_ret : ret
end
#=============================================================================

View File

@@ -52,7 +52,7 @@ module Battle::ItemEffects
def self.trigger(hash, *args, ret: false)
new_ret = hash.trigger(*args)
return (new_ret != nil) ? new_ret : ret
return (!new_ret.nil?) ? new_ret : ret
end
#=============================================================================

View File

@@ -9,12 +9,12 @@ module Battle::PokeBallEffects
def self.isUnconditional?(ball, battle, battler)
ret = IsUnconditional.trigger(ball, battle, battler)
return (ret != nil) ? ret : false
return (!ret.nil?) ? ret : false
end
def self.modifyCatchRate(ball, catchRate, battle, battler)
ret = ModifyCatchRate.trigger(ball, catchRate, battle, battler)
return (ret != nil) ? ret : catchRate
return (!ret.nil?) ? ret : catchRate
end
def self.onCatch(ball, battle, pkmn)

View File

@@ -277,14 +277,12 @@ module RecordedBattle::PlaybackHelper
trainer.each do |tr|
if tr.length == 4 # Player
t = Player.new(tr[1], tr[0])
t.id = tr[2]
t.badges = tr[3]
ret.push(t)
else # NPCTrainer
t = NPCTrainer.new(tr[1], tr[0])
t.id = tr[2]
ret.push(t)
end
t.id = tr[2]
ret.push(t)
end
return ret
end