#===============================================================================
# Increases the user's and its ally's Defense and Special Defense by 1 stage
# each, if they have Plus or Minus. (Magnetic Flux)
#===============================================================================
# NOTE: In Gen 5, this move should have a target of UserSide, while in Gen 6+ it
# should have a target of UserAndAllies. This is because, in Gen 5, this
# move shouldn't call def pbSuccessCheckAgainstTarget for each Pokémon
# currently in battle that will be affected by this move (i.e. allies
# aren't protected by their substitute/ability/etc., but they are in Gen
# 6+). We achieve this by not targeting any battlers in Gen 5, since
# pbSuccessCheckAgainstTarget is only called for targeted battlers.
class PokeBattle_Move_137 < PokeBattle_Move
def ignoresSubstitute?(user); return true; end
def pbMoveFailed?(user,targets)
@validTargets = []
@battle.eachSameSideBattler(user) do |b|
next if !b.hasActiveAbility?([:MINUS,:PLUS])
next if !b.pbCanRaiseStatStage?(PBStats::DEFENSE,user,self) &&
!b.pbCanRaiseStatStage?(PBStats::SPDEF,user,self)
@validTargets.push(b)
end
if @validTargets.length==0
@battle.pbDisplay(_INTL("But it failed!"))
return true
end
return false
end
def pbFailsAgainstTarget?(user,target)
return false if @validTargets.any? { |b| b.index==target.index }
return true if !target.hasActiveAbility?([:MINUS,:PLUS])
@battle.pbDisplay(_INTL("{1}'s stats can't be raised further!",target.pbThis))
return true
end
def pbEffectAgainstTarget(user,target)
showAnim = true
if target.pbCanRaiseStatStage?(PBStats::DEFENSE,user,self)
if target.pbRaiseStatStage(PBStats::DEFENSE,1,user,showAnim)
showAnim = false
end
end
if target.pbCanRaiseStatStage?(PBStats::SPDEF,user,self)
target.pbRaiseStatStage(PBStats::SPDEF,1,user,showAnim)
end
end
def pbEffectGeneral(user)
return if pbTarget(user)==PBTargets::UserAndAllies
@validTargets.each { |b| pbEffectAgainstTarget(user,b) }
end
end